export const tokw = (text: string): string => {
  const n = parseInt(text);
  if (Math.abs(n) >= 0 && Math.abs(n) < 1000) {
    return text;
  } else if (Math.abs(n) >= 1000 && Math.abs(n) < 10000) {
    return (n / 1000).toFixed(n % 1000 == 0 ? 0 : 1) + "k";
  } else if (Math.abs(n) >= 10000 && Math.abs(n) < 100000000) {
    return (n / 10000).toFixed(n % 10000 == 0 ? 0 : 1) + "w";
  } else {
    return (n / 100000000).toFixed(n % 100000000 == 0 ? 0 : 1) + "亿";
  }
  return text;
};

export const numKW = (num: number) => {
  num = num * 1;
  if (num >= 1e3 && num < 1e4) {
    return (num / 1e3).toFixed(1) + "k";
  } else if (num >= 1e4 && num < 1e8) {
    return (num / 1e4).toFixed(1) + "w";
  } else if (num >= 1e8) {
    return (num / 1e8).toFixed(1) + "亿";
  } else {
    return num || 0;
  }
};
